<script type="text/javascript">

$(document).ready(function(){
	$("#AuthorlinkAuthor").autocomplete({
		delay: 0,
	    source: '/authorlinks/autocomplete.json',
	    minLength: 2,
	    autoFocus: true
	}); 
	$("#AuthorlinkAuthor").autocomplete({	    
	    select: function( event, ui ) {
	    	selected_id = ui.item.id;
	    	$('#AuthorlinkAuthorId').append('<input id="AuthorlinkAuthorId" type="hidden" name="data[Authorlink][author_id]" value="' + selected_id + '" />');
	    	$('#AuthorlinkAuthorId').submit();
		}    
	});

	$("input:submit").button();
});
</script>

<div class="extauthors form">
<?php echo $this->Form->create('Authorlink'); ?>
	<fieldset>
		<legend><?php echo __('Add Author'); ?></legend>
		<?php 
			echo $this->Form->hidden('recordid', array('value' => $record_id));
			echo $this->Form->hidden('recordtype_id', array('value' => $recordtype_id));
			echo $this->Form->hidden('authortype_id', array('value' => $authortype_id));
		?>
		<table width="100%" class="invisibletable">
  <tr>
    <td width="15%" align="right">Преподаватель КГМУ</td>
    <td width="2%" align="right"><font color="red">*</font></td>
    <td width="45%">
    <?php  
    	echo $this->Form->hidden('author_id', array('value' => ''));
		echo $this->Form->input('Author', array('label' => '')); 
	?>
	</td>
  </tr>
  </table>
  </fieldset>
  	<br />
<?php echo $this->Form->end(__('Submit')); ?>
</div>